<div class="login-main">
    <header class="layui-elip">后台{{title}}</header>
    <form class="layui-form">
        <div class="layui-input-inline">
            {{!-- <input type="text" name="name" lay-verify="phone" placeholder="手机号码" autocomplete="off" class="layui-input"> --}}
            <input type="text" name="name"  placeholder="手机号码" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-input-inline">
            <input type="password" name="password" required lay-verify="pass" placeholder="密码" autocomplete="off" class="layui-input">
        </div>
         <div class="layui-input-inline login-btn">
            <button class="layui-btn" lay-filter="doLogin" lay-submit>登录</button>
            <button type="reset" class="layui-btn layui-btn-warm">重置</button>
        </div>

        <div class="login-text">还没有帐号？<a href="/manager/register" style="color: #fff;">去注册</a></div>
    </form>
</div>



<script>
layui.use(['form','jquery','layer'], function(){
    var form = layui.form;
    var $ = layui.$ 

    //form.verify({
    //    pass: [
    //        /^[\S]{6,12}$/
    //        ,'密码必须6到12位，且不能出现空格'
    //    ] 
    // });  
     
    form.on('submit(doLogin)', function(data){
        $.ajax({
            url: './login/doLogin',
            type:'post',
            data: data.field,
            success: function(resData){
                console.log(resData.data);
                if(resData.data === true)
                    return window.location.replace('/manager/index');
                else
                    return layer.msg('错误：帐号和密码错误', {icon: 5}); 
                
            },
            error: function(err){
                console.log(err);
            }
        })
        return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });
});
</script>


<style>
    body{background: #393D49}
</style>

